/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package replic;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import replic.commons.OutputMessage;

/**
 *
 * @author leoomoreira
 */
public class RepliCAgentListenerThread extends Thread {
    
    private RepliCAgentListener repliCAgentListener;
    private Socket socket;
    
    public RepliCAgentListenerThread(RepliCAgentListener repliCAgentListener, Socket socket) {
        this.repliCAgentListener = repliCAgentListener;
        this.socket = socket;
    }

    @Override
    public void run() {
        OutputMessage.println("RepliCListenerThread Starting");
        ObjectOutputStream outputStream = null;
        ObjectInputStream inputStream = null;
        boolean proceed = true;
        try {
            outputStream = new ObjectOutputStream(socket.getOutputStream());
            inputStream = new ObjectInputStream(socket.getInputStream());
        } catch (IOException ex) {
            OutputMessage.println("RepliCListenerThread: Closing client connection");
            proceed = false;
        }
        OutputMessage.println("RepliCListenerThread: Started");

        while (proceed && socket != null && socket.isConnected()) {
            try {
                Object message = inputStream.readObject();
            } catch (ClassNotFoundException ex) {
                
            } catch (IOException ex) {
                
            }
        }
    }
    
}